home *** CD-ROM | disk | FTP | other *** search
/ The Trig Explorer / The Trig Explorer.iso / pc / explorer / function.dxr / 00173.ls < prev    next >
Encoding:
Text File  |  1997-07-22  |  3.0 KB  |  91 lines

  1. on mouseDown me
  2.   set xCenter to ((the left of sprite 4 + the right of sprite 4) / 2) + 1
  3.   set yCenter to ((the top of sprite 4 + the bottom of sprite 4) / 2) + 2
  4.   set radius to the width of sprite 4 / 2
  5.   set the cursor of sprite the spriteNum of me to [member "Closed Hand", member "Closed Hand Mask"]
  6.   repeat while the stillDown
  7.     set mx to the mouseH
  8.     set my to the mouseV
  9.     set xAtMouse to mx - xCenter
  10.     set yAtMouse to my - yCenter
  11.     if xAtMouse <> 0 then
  12.       set angleAtMouse to atan(float(abs(yAtMouse)) / float(abs(xAtMouse)))
  13.       if angleAtMouse = 0 then
  14.         set yAtCircle to 0
  15.         set xAtCircle to radius * (xAtMouse / abs(xAtMouse))
  16.       else
  17.         set yAtCircle to sin(angleAtMouse) * float(radius) * (yAtMouse / abs(yAtMouse))
  18.         set xAtCircle to cos(angleAtMouse) * float(radius) * (xAtMouse / abs(xAtMouse))
  19.       end if
  20.     else
  21.       set xAtCircle to 0
  22.       if yAtMouse <> 0 then
  23.         set yAtCircle to radius * (yAtMouse / abs(yAtMouse))
  24.       else
  25.         set yAtCircle to radius
  26.       end if
  27.     end if
  28.     set the locH of sprite the clickOn to xCenter + xAtCircle
  29.     set the locV of sprite the clickOn to yCenter + yAtCircle
  30.     drawLine(6, yCenter, xCenter, the locV of sprite the clickOn, the locH of sprite the clickOn)
  31.     set the locH of sprite 5 to ((the left of sprite 6 + the right of sprite 6) / 2) - 10
  32.     set the locV of sprite 5 to ((the top of sprite 6 + the bottom of sprite 6) / 2) - 30
  33.     set dy to float(yCenter - the locV of sprite the clickOn)
  34.     set dy to -dy
  35.     set dx to float(xCenter - the locH of sprite the clickOn)
  36.     if dx = 0 then
  37.       if dy < 0 then
  38.         set theta1 to float(1.5 * PI)
  39.       else
  40.         set theta1 to float(PI / 2.0)
  41.       end if
  42.     else
  43.       if dx > 0 then
  44.         set theta1 to float(atan(float(dy / dx)))
  45.         if theta1 < 0 then
  46.           set theta1 to float(theta1) + (2.0 * PI)
  47.         end if
  48.       else
  49.         set theta1 to float(atan(float(dy / dx))) + PI
  50.       end if
  51.     end if
  52.     set the floatPrecision to 2
  53.     if theta1 > PI then
  54.       set theta1 to theta1 - PI
  55.     else
  56.       set theta1 to theta1 + PI
  57.     end if
  58.     set temp to theta1 * 180.0 / PI
  59.     if temp = 360.0 then
  60.       put "0.0" into field "theta"
  61.     else
  62.       put temp into field "theta"
  63.     end if
  64.     if dx <> 0 then
  65.       put float(float(sqrt(2.0)) * float(cos(theta1))) into field "X1"
  66.     else
  67.       put "0.0" into field "X1"
  68.     end if
  69.     put float(float(sqrt(2.0)) * float(sin(theta1))) into field "Y1"
  70.     if field "X1" = 0 then
  71.       set the locH of sprite 26 to 486
  72.     else
  73.       set the locH of sprite 26 to 700
  74.     end if
  75.     put "(" & field "X1" & "," & field "Y1" & ")" into field "x-y"
  76.     updateStage()
  77.   end repeat
  78.   set the cursor of sprite the spriteNum of me to [member "hand", member "Hand Mask"]
  79. end
  80.  
  81. on beginSprite me
  82.   set the cursor of sprite the spriteNum of me to [member "hand", member "Hand Mask"]
  83.   put "19.12" into field "theta"
  84.   put "0.48" into field "Y1"
  85.   put "1.33" into field "X1"
  86. end
  87.  
  88. on endSprite me
  89.   set the cursor of sprite the spriteNum of me to 0
  90. end
  91.